package com.network;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;

import com.network.network.ResponseCallback;

/**
 * Created by Bruce on 2017/7/1.
 */

public class BaseActivity extends AppCompatActivity {
    private Handler mHandler = new Handler() {
        ResponseCallback responseCallback;

        @Override
        public void handleMessage(Message msg) {
            responseCallback = (ResponseCallback) msg.obj;
            if (msg.arg1 == 1) {//请求成功
                Bundle data = msg.getData();
                String result = data.getString("result");
                responseCallback.onResponseOk(result);
            } else {
                responseCallback.onResponseError(msg.arg2 + "");
            }
        }
    };

    protected Handler getHandler() {
        return mHandler;
    }
}
